<template>
  <div class="simple-app-container">
    <div v-loading="loading" v-permission="['base-data:product:info:add']">
      <a-form ref="form" :label-col="{ span: 6 }" :wrapper-col="{ span: 14 }" :model="formData" :rules="rules">
        <a-row>
          <a-col :md="6" :sm="24">
            <a-form-item label="生产单号" name="productionNumber">
              <a-input v-model:value="formData.productionNumber" allow-clear placeholder="请输入生产单号" :disabled="isView" />
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="24">
            <a-form-item label="商品条码" name="goodsCode">
              <production-selector v-model:value="formData.goodsCode" placeholder="选择商品"
                @product-selected="handleProductSelected" :disabled="isView" />
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="24">
            <a-form-item label="商品名称" name="goodsName">
              <a-input v-model:value="formData.goodsName" allow-clear placeholder="请输入商品名称" :disabled="isView" />
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="24">
            <a-form-item label="计量单位" name="goodsSpecifications">
              <a-input v-model:value="formData.goodsSpecifications" allow-clear placeholder="请输入计量单位"
                :disabled="isView" />
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="24">
            <a-form-item label="多属性" name="marque">
              <a-input v-model:value="formData.marque" allow-clear placeholder="请输入多属性" :disabled="isView" />
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="24">
            <a-form-item label="订购数量" name="orderQuantity">
              <a-input-number v-model:value="formData.orderQuantity" :min="1" class="number-input" placeholder="请输入订购数量"
                :disabled="isView" />
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="24">
            <a-form-item label="生产数量" name="productionQuantity" required>
              <a-input-number v-model:value="formData.productionQuantity" :min="1" class="number-input"
                placeholder="请输入生产数量" :disabled="isView" />
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="24">
            <a-form-item label="销售订单号" name="salesale">
              <a-input v-model:value="formData.salesale" allow-clear placeholder="请输入销售订单号" :disabled="isView" />
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="24">
            <a-form-item label="客户原始单号" name="orderDate">
              <a-input v-model:value="formData.orderDate" allow-clear placeholder="请输入客户原始单号" :disabled="isView" />
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="24">
            <a-form-item label="计划完工" required name="completionDate">
              <a-date-picker v-model:value="formData.completionDate" style="width:100%;" allow-clear
                :disabled-date="disabledDate" placeholder="请选择计划完工" :disabled="isView" />
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="24">
            <a-form-item label="单据备注" name="orderRemark">
              <a-textarea v-model:value="formData.orderRemark" show-count allow-clear :rows="1" :maxlength="500"
                placeholder="请输入备注" :disabled="isView" />
            </a-form-item>
          </a-col>
        </a-row>
        <a-col :span="24">
          <a-menu v-model:selectedKeys="selectedKeys" mode="horizontal" class="custom-menu" @click="handleTabChange">
            <a-menu-item key="required">1、所需物料</a-menu-item>
            <a-menu-item key="production">2、生产工序</a-menu-item>
          </a-menu>
        </a-col>
        <a-row>
          <a-col :span="24">
            <vxe-grid ref="grid" resizable show-overflow highlight-hover-row keep-source row-id="id" height="390"
              :data="currentTableData" :columns="productColumns" :loading="tableLoading" :checkbox-config="{
                checkField: 'checked',
                trigger: 'row'
              }">
              <template #toolbar>
                <a-space style="margin-bottom: 10px;">
                  <a-button type="primary" :icon="h(PlusOutlined)" @click="addRow">插入行</a-button>
                  <a-button danger :icon="h(DeleteOutlined)" @click="delRow">一键移除</a-button>
                </a-space>
              </template>

              <!-- 物料编码列的表头 -->
              <template #material-header>
                <div class="material-header">
                  <span>编码</span>
                  <QuestionCircleOutlined class="select-icon" @click="$refs.materialSelector.show()" />
                </div>
              </template>

              <!-- 物料编码单元格插槽 -->
              <template #material-code="{ row }">
                <div class="material-code-cell">
                  <production-selector v-model="row.code" :materialCode="row.code" placeholder="请选择商品"
                    @product-selected="(product) => handleMaterialSelected(product, row)" :disabled="isView" />
                </div>
              </template>

              <!-- 物料名称单元格插槽 -->
              <template #material-name="{ row }">
                <a-input v-model:value="row.name" placeholder="名称" :disabled="isView" />
              </template>

              <!-- 物料单位单元格插槽 -->
              <template #material-unit="{ row }">
                <a-input v-model:value="row.unit" placeholder="单位" :disabled="isView" />
              </template>

              <!-- 物料数量单元格插槽 -->
              <template #material-quantity="{ row }">
                <div class="number-cell">
                  <a-input-number v-model:value="row.quantity" :min="1" placeholder="数量" class="right-aligned-input"
                    :disabled="isView" />
                </div>
              </template>

              <!-- 物料单价单元格插槽 -->
              <template #material-price="{ row }">
                <div class="number-cell">
                  <a-input v-model:value="row.purchasingPrice" :min="0" placeholder="单价" class="right-aligned-input"
                    :disabled="isView" />
                </div>
              </template>

              <!-- 工序执行顺序插槽 -->
              <template #process-order="{ row }">
                <div class="number-cell">
                  <a-input-number v-model:value="row.executeProcesses" :min="1" placeholder="顺序"
                    class="right-aligned-input" :disabled="isView" />
                </div>
              </template>

              <!-- 工序名称插槽 -->
              <template #process-name="{ row }">
                <a-input v-model:value="row.processesName" placeholder="工序名称" :disabled="isView" />
              </template>

              <!-- 负责人员插槽 -->
              <template #process-responsible="{ row }">
                <a-select v-model:value="row.leader" show-search placeholder="选择负责人" :filter-option="false"
                  @search="handleStaffSearch" style="width: 100%" :disabled="isView">
                  <a-select-option v-for="staff in staffSearchResults" :key="staff.id" :value="staff.name">
                    {{ staff.name }}
                  </a-select-option>
                </a-select>
              </template>

              <!-- 计费方式插槽 -->
              <template #process-billing="{ row }">
                <a-select v-model:value="row.billingMethod" placeholder="计费方式" style="width: 100%" :disabled="isView">
                  <a-select-option value="time">计时</a-select-option>
                  <a-select-option value="piece">计件</a-select-option>
                  <a-select-option value="fixed">固定工资</a-select-option>
                </a-select>
              </template>

              <!-- 加工单价插槽 -->
              <template #process-price="{ row }">
                <div class="number-cell">
                  <a-input-number v-model:value="row.wages" :min="0" placeholder="加工单价" class="right-aligned-input"
                    @change="handleProcessPriceChange(row)" :disabled="isView" />
                </div>
              </template>

              <!-- 所需费用插槽 -->
              <template #process-required-cost="{ row }">
                <div class="number-cell">
                  <a-input-number v-model:value="row.processRequiredCost" :min="0" placeholder="所需费用"
                    class="right-aligned-input" :disabled="isView" />
                </div>
              </template>

              <!-- 计划完工时间插槽 -->
              <template #process-completion-time="{ row }">
                <a-date-picker v-model:value="row.processCompletionTime" style="width: 100%"
                  :disabled-date="disabledDate" placeholder="选择完工时间" :disabled="isView" />
              </template>

              <!-- 备注插槽 -->
              <template #process-note="{ row }">
                <div class="note-cell">
                  <a-tooltip :title="row.processNote" placement="topLeft">
                    <a-input v-model:value="row.processNote" :maxlength="100" show-count placeholder="请输入备注（最多100字）"
                      :disabled="isView" />
                  </a-tooltip>
                </div>
              </template>
            </vxe-grid>
          </a-col>
        </a-row>
        <a-row :gutter="24" class="summary-row" v-if="selectedKeys[0] === 'required'">
          <a-col :span="17"></a-col>
          <a-col :span="3">
            <div class="summary-item">
              <span class="summary-value">{{ totalQuantity }}</span>
            </div>
          </a-col>
          <a-col :span="3">
            <div class="summary-item">
              <span class="summary-value">{{ totalPrice }}</span>
            </div>
          </a-col>
        </a-row>
        <a-row :gutter="24" class="summary-row" v-else>
          <a-col :span="12"><span class="summary-value vacant"></span></a-col>
        </a-row>
      </a-form>
      <div class="form-modal-footer">
        <a-space>
          <a-button v-if="!isView" type="primary" @click="submit">保存</a-button>
          <a-button @click="closeDialog">关闭</a-button>
        </a-space>
      </div>
    </div>
  </div>
</template>
<script lang="ts">
import { defineComponent, h, onMounted, ref, computed } from 'vue';
import dayjs from 'dayjs';
import { PlusOutlined, DeleteOutlined, QuestionCircleOutlined } from '@ant-design/icons-vue';
// import { validCode } from '@/utils/validate';
// import * as api from '@/api/base-data/product/info';
// import * as propertyApi from '@/api/base-data/product/property';
import { tasksProductionApi } from '/@/api/base-data/product/production-tasks';
// import * as storeApi from '@/api/base-data/store-center';
import { useRoute } from 'vue-router';
import { bomProductApi } from '/@/api/base-data/product/bom-product'
import { PageWrapper } from '/@/components/Page';
import { useTitle } from '/@/hooks/web/useTitle';
import { Modal } from 'ant-design-vue';

export default defineComponent({
  name: 'AddProduct',
  components: {
    PageWrapper
  },
  setup() {
    const route = useRoute();
    const processData = ref({});
    const loading = ref(false);
    const grid = ref(null);
    // 判断是否是查看模式
    const isView = computed(() => route.query.mode === 'view');
    const isEdit = computed(() => route.query.mode === 'edit');

    // 修改标题计算属性
    const pageTitle = computed(() => {
      if (isView.value) return '查看生产任务';
      if (isEdit.value) return '编辑生产任务';
      return '新增生产任务';
    });

    // 动态设置页面标题
    const setPageTitle = () => {
      let title = '新增生产任务';
      if (isView.value) {
        title = '查看生产任务';
      } else if (isEdit.value) {
        title = '编辑生产任务';
      }
      useTitle(title);
      // 更新路由 meta 的标题
      route.meta.title = title; ``
    };

    onMounted(() => {
      setPageTitle();
      const id = route.params.id;
      if (!id) {
        console.error('No ID provided');
        return;
      }

      try {
        loading.value = true;
        // console.log('Process ID:', id);
      } catch (error) {
        console.error('Failed to fetch process data:', error);
      } finally {
        loading.value = false;
      }
    });

    return {
      processData,
      loading,
      isView,
      isEdit,
      pageTitle,
      grid,
    };
  },
  data() {
    return {
      PlusOutlined,
      DeleteOutlined,
      QuestionCircleOutlined,
      h,
      selectedKeys: ['required'], // 默认选中"所需物料"
      itemMenu: "required",
      // 表单数据
      formData: {
        orderQuantity: 1, // 默认值为1
        productionQuantity: 1, // 默认值为1
      },
      // productType: undefined,
      productBundles: [],
      // 属性列表
      modelorList: [],
      // 表单校验规则
      rules: {
        goodsCode: [
          { required: true, message: '请选择商品' }
        ],
        orderQuantity: [
          { required: true, message: '请输入订购数量' },
          { type: 'number', min: 1, message: '订购数量必须大于0' }
        ],
        productionQuantity: [
          { required: true, message: '请输入生产数量' },
          { type: 'number', min: 1, message: '生产数量必须大于0' }
        ],
        completionDate: [
          { required: true, message: '请选择计划完工时间' }
        ]
      },
      currentProduct: null, // 存储当前选择的生产商品
      currentTableData: [],
      tableLoading: false,
      tableCache: {
        required: [], // 物料数据缓存
        production: [] // 工序数据缓存
      },
      // currentEditRow: null, // 当前编辑的行
      // 添加模拟数据
      mockMaterials: [],
      // 添加工序模拟数据
      mockProcesses: [],

      // 添加人员模拟数据
      mockStaff: [
        { id: '1', name: '张三' },
        { id: '2', name: '李四' },
        { id: '3', name: '王五' },
        { id: '4', name: '赵六' }
      ],

      // 人员搜索结果
      staffSearchResults: [],
      staffSearchValue: '',
    };
  },

  computed: {
    // 计算数量合计
    totalQuantity() {
      return this.currentTableData.reduce((sum, item) => {
        return sum + (Number(item.quantity) || 0);
      }, 0).toFixed(2);
    },
    // 修改为单价合计
    totalPrice() {
      return this.currentTableData.reduce((sum, item) => {
        return sum + (Number(item.purchasingPrice) || 0);
      }, 0).toFixed(2);
    },
    // 根据选中的菜单返回不同的列
    productColumns() {
      const baseColumns = [
        { type: 'seq', width: 60, title: '序号' },
        { type: 'checkbox', width: 50, title: '' }
      ];
      const materialColumns = [
        {
          field: 'code',
          title: '编码',
          width: 220,
          slots: {
            default: 'material-code',
            header: 'material-header'
          }
        },
        {
          field: 'name',
          title: '名称',
          minWidth: 260,
          slots: { default: 'material-name' }
        },
        {
          field: 'unit',
          title: '单位',
          width: 200,
          slots: { default: 'material-unit' }
        },
        {
          field: 'quantity',
          title: '数量',
          width: 200,
          slots: { default: 'material-quantity' }
        },
        {
          field: 'purchasingPrice',
          title: '单价',
          width: 200,
          slots: { default: 'material-price' }
        }
      ];
      const processColumns = [
        {
          field: 'executeProcesses',
          title: '执行顺序',
          width: 160,
          slots: { default: 'process-order' }
        },
        {
          field: 'processesName',
          title: '工序名称',
          width: 150,
          slots: { default: 'process-name' }
        },
        {
          field: 'leader',
          title: '负责人员',
          width: 150,
          slots: { default: 'process-responsible' }
        },
        {
          field: 'billingMethod',
          title: '计费方式',
          width: 150,
          slots: { default: 'process-billing' },
          defaultValue: 'time'
        },
        {
          field: 'wages',
          title: '加工单价',
          width: 150,
          align: 'right',
          slots: { default: 'process-price' }
        },
        {
          field: 'processRequiredCost',
          title: '所需费用',
          width: 150,
          align: 'right',
          slots: { default: 'process-required-cost' }
        },
        {
          field: 'processCompletionTime',
          title: '计划完工时间',
          width: 180,
          slots: { default: 'process-completion-time' }
        },
        {
          field: 'processNote',
          title: '备注',
          minWidth: 200,
          slots: { default: 'process-note' }
        }
      ];
      return [
        ...baseColumns,
        ...(this.selectedKeys[0] === 'required' ? materialColumns : processColumns)
      ];
    },
  },
  created() {
    // 初始化表单数据
    // this.initData();
    this.initFormData();
  },

  methods: {
    handleProductSelected(product) {
      console.log("Product selected:", product);
      this.currentProduct = product;
      this.formData.goodsCode = product.code;
      this.formData.goodsName = product.name;
      this.formData.goodsSpecifications = product.unit;
      // 加载BOM物料
      this.currentTableData = [];
      this.loadBomMaterials(product.id);
    },

    handleTabChange({ key }) {
      // 保存当前数据到缓存
      this.tableCache[this.selectedKeys[0]] = [...this.currentTableData];
      // 切换菜单
      this.selectedKeys = [key];
      this.itemMenu = key;
      // 从缓存加载数据
      this.currentTableData = [...(this.tableCache[key] || [])];
      // 如果缓存为空，加载对应的默认数据
      if (this.currentTableData.length === 0) {
        if (key === 'required') {
          // 加载物料默认数据
          this.currentTableData = this.mockMaterials.map(item => ({
            ...item,
          }));
        } else {
          // 加载工序默认数据
          this.currentTableData = this.mockProcesses.map(item => ({
            ...item,
            processBilling: 'time' // 确保工序数据有默认计费方式
          }));
        }
        // 更新缓存
        this.tableCache[key] = [...this.currentTableData];
      }
    },
    //物料工序表
    resetTableData() {
      this.currentTableData = [];
      this.tableCache = {
        required: [],
        production: []
      };
      this.tableLoading = false;
    },
    initData() {
      if (this.selectedKeys[0] === 'production') {
        // 初始化工序数据
        this.tableCache.production =
          this.currentTableData = [...this.tableCache.production];
      } else {
        // 初始化物料数据
        this.tableCache.required = this.mockMaterials.map(item => ({
          ...item,
        }));
        this.currentTableData = [...this.tableCache.required];
      }
    },
    closeDialog() {
      this.$utils.closeCurrentPage();
      this.$router.go(-1);
    },

    async initFormData() {
      this.staffSearchResults = this.mockStaff;
      // 初始化生产单号
      this.formData.productionNumber = await tasksProductionApi.getOrderNumber().then((res) => {
        console.log("======================>", res);
        return res
      })
      //初始化物料列表
      this.modelorList = [];
      //初始化工序列表
      this.productBundles = [];
    },
    async submit() {
      let valid = true;

      await this.$refs.form.validate().then((res) => {
        valid = res;
      });

      if (!valid) {
        this.$message.error('表单验证失败');
        return;
      }

      this.loading = true;
      try {
        const params = {
          ...this.formData,
          materials: this.mockMaterials,
          processes: this.mockProcesses
        }
        await tasksProductionApi.addProduct(params);
        // await bomProductApi.addMaterial(params);
        this.$msg.createSuccess('新增成功！');
        this.$emit('confirm');
        this.closeDialog();
      } catch (error) {
        console.error('API Error:', error);
        this.$message.error('新增失败');
      } finally {
        this.loading = false;
      }
    },
    //添加行处理
    addRow() {
      if (!this.currentProduct) {
        this.$message.warning('请先选择商品');
        return;
      }
      if (this.selectedKeys[0] === 'required') {
        // 添加物料行
        const newRow = Object.assign({}, {
          productId: undefined, // 确保初始值为空字符串而不是 undefined
          name: '',
          unit: '',
          quantity: 1,
          purchasingPrice: ''
        });
        this.currentTableData.push(newRow);
      } else {
        // 添加工序行
        const newRow = Object.assign({}, {
          processOrder: this.currentTableData.length + 1,
          processCode: '',
          processName: '',
          processResponsible: undefined,
          processBilling: 'time', // 默认为计时
          processPrice: 0,
          processRequiredCost: 0,
          processCompletionTime: null,
          processNote: ''
        });
        this.currentTableData.push(newRow);
      }
      // 更新缓存
      this.tableCache[this.selectedKeys[0]] = [...this.currentTableData];
    },
    //删除行处理
    delRow() {
      const $grid = this.$refs.grid;
      if (!$grid) {
        this.$message.warning('表格实例未找到');
        return;
      }

      // 获取选中行
      const selectedRows = $grid.getCheckboxRecords();
      if (!selectedRows || selectedRows.length === 0) {
        this.$message.warning('请选择要删除的行');
        return;
      }

      try {
        // 从表格数据中移除选中行
        const selectedIds = selectedRows.map(row => row.id);
        this.currentTableData = this.currentTableData.filter(
          row => !selectedIds.includes(row.id)
        );

        // 清除选中状态
        $grid.clearCheckboxRow();

        // 如果需要同步到后端，可以调用删除 API
        // await bomProductApi.deleteMaterials(selectedIds);

        this.$message.success('删除成功');
      } catch (error) {
        console.error('删除失败:', error);
        this.$message.error('删除失败');

        // 如果删除失败，可以重新加载数据
        // await loadTableData();
      }
    },
    disabledDate(current) {
      // 禁用今天之前的日期
      return current && current < dayjs().startOf('day');
    },
    // 修改物料选择处理方法
    handleMaterialSelected(product, row) {
      console.log("product", product);
      if (!product) return;
      // 检查是否选择了当前生产的商品
      if (product.code === this.currentProduct?.code) {
        this.$message.error('物料不能选择即将生产的商品本身');
        row.code = undefined
        return;
      }
      row.code = product.code
      row.name = product.name
      row.unit = product.unit
      // 更新缓存
      this.tableCache[this.selectedKeys[0]] = [...this.currentTableData];
    },
    // 修改加载BOM物料的方法
    async loadBomMaterials(id) {
      this.tableLoading = true;
      try {
        const params = {
          pageIndex: 1,
          pageSize: 500,
          id: id
        }
        console.log("params", params);
        const resMaterial = await bomProductApi.queryMaterialPage(params);
        this.mockMaterials = resMaterial.datas;
        console.log("mockMaterials", this.mockMaterials);

        const param = {
          pageIndex: 1,
          pageSize: 500,
          productId: id
        }
        const resProcess = await bomProductApi.queryProcessPage(param);
        this.mockProcesses = resProcess.datas.map(item => ({
          ...item,
          processRequiredCost: item.wages || 0
        }));
        // console.log("mockProcesses", this.mockProcesses);

        this.initData();
        this.selectedKeys = ['required'];
        // 更新缓存
        // this.tableCache.required = [...this.currentTableData];
        console.log("this.tableCache.required", this.tableCache.required);
      } catch (error) {
        console.error('Load BOM materials error:', error);
        this.$message.error('加载物料清单失败');
      } finally {
        this.tableLoading = false;
      }
    },
    // 处理人员搜索
    handleStaffSearch(value) {
      if (!value) {
        this.staffSearchResults = this.mockStaff;
        return;
      }
      // 模糊搜索人员
      this.staffSearchResults = this.mockStaff.filter(staff =>
        staff.name.toLowerCase().includes(value.toLowerCase())
      );
    },

    // 处理加工单价变化
    handleProcessPriceChange(row) {
      // 更新所需费用
      row.processRequiredCost = row.processPrice;
    }
  },
  beforeUnmount() {
    this.resetTableData();
  }
});
</script>
<style lang="less" scoped>
.summary-row {
  margin-top: 16px;
  padding: 12px 24px;
  background-color: #fafafa;
  border-radius: 4px;
  min-height: 48px;
  display: flex;
  align-items: center;

  .summary-item {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding-right: 24px;
    width: 100%;

    .summary-label {
      font-weight: bold;
      margin-right: 8px;
      white-space: nowrap;
    }

    .summary-value {
      color: #1890ff;
      font-size: 16px;
      min-width: 80px;
      text-align: right;
      padding-right: 8px;
    }
  }
}

/deep/ .ant-menu-item {
  min-width: 120px;
  padding: 0 24px;
  text-align: center;
}

.custom-menu {
  margin-bottom: 16px;
  border-bottom: 1px solid #f0f0f0;
}

.material-header {
  display: flex;
  align-items: center;
  justify-content: space-between;

  .select-icon {
    cursor: pointer;
    color: #1890ff;

    &:hover {
      color: #40a9ff;
    }
  }
}

.material-code-cell {
  display: flex;
  align-items: center;
  gap: 8px;

  .ant-input {
    flex: 1;
  }

  .select-icon {
    cursor: pointer;
    color: #1890ff;

    &:hover {
      color: #40a9ff;
    }
  }
}

.number-cell {
  display: flex;
  justify-content: flex-end;
  align-items: center;

  .right-aligned-input {
    width: 100%;
  }
}


// 确保表格单元格内的文字右对齐
:deep(.vxe-cell--align-right) {
  text-align: right !important;
}

// 确保表格和合计行的对齐
.vxe-grid {
  :deep(.vxe-table--body-wrapper) {
    .vxe-body--row {
      .vxe-body--column {
        &.col--align-right {
          padding-right: 24px;
        }
      }
    }
  }
}

// 添加工序相关样式
.process-cell {
  width: 100%;

  .ant-select,
  .ant-picker {
    width: 100%;
  }

  .ant-input-number {
    width: 100%;
  }
}

// 备注单元格样式
.note-cell {
  width: 100%;
  position: relative;

  :deep(.ant-tooltip) {
    max-width: 500px; // 设置tooltip的最大宽度

    .ant-tooltip-inner {
      white-space: pre-wrap; // 保留换行
      word-break: break-all; // 允许在任意字符间换行
    }
  }

  .ant-input {
    width: 100%;
    resize: none;
  }
}

// 修改文本域样式
:deep(.ant-input-textarea-show-count) {
  width: 100%;

  .ant-input {
    width: 100%;
    resize: none;

    &:hover {
      cursor: pointer; // 鼠标悬停时显示指针
    }
  }

  // 字数统计样式
  .ant-input-data-count {
    position: absolute;
    bottom: 0;
    right: 8px;
    font-size: 12px;
    color: rgba(0, 0, 0, 0.45);
  }
}
</style>
